<?php


namespace app\controllers;


use app\components\BaseController;

class HomeController extends BaseController
{
    public function actionIndex()
    {
//        \Yii::$app->language = '';

        return $this->render('index');
    }

    public function actionDb()
    {
        $data = [];
        foreach (range(1, 10000) as $item) {
//            $news = new News();
//            $news->title = '新闻标题' . $item;
//            $news->save();

            $data[] = ['新闻标题' . $item];
        }

        \app\models\News::find()->createCommand()->batchInsert('news', ['title'], $data)->execute();


//
//        $news = News::find()->where(['id' => 35])->one();
////        $data = $news->getAttributes();
////        $news->delete();
//        $news->title = '新标题';
//        $news->save();

//        $news_s = News::find()->all();
//        echo count($news_s);
//        foreach ($news_s as $news_) {
//            $news_->views = 0;
//            $news_->save();
//        }

        return '';
    }

}